Imports BusinessLayer
Imports EntityLayer

Partial Class ListaEvaluacionSolicitudPedido
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Call ListarSolicitudes()
        End If
    End Sub

    Private Sub ListarSolicitudes()
        dgDatos.DataSource = SolicitudPedidoBL.ListarTodo
        dgDatos.DataBind()
    End Sub


    Protected Sub dgDatos_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles dgDatos.RowCommand
        Dim index As Integer = Integer.Parse(e.CommandArgument.ToString())
        Dim row As GridViewRow = dgDatos.Rows(index)
        Dim key As DataKey = dgDatos.DataKeys(row.RowIndex)

        Try
            If e.CommandName = "Prod" Then
                MostrarProductos((key(0).ToString()))
            End If
            If e.CommandName = "Edt" Then
                Session("Estado") = row.Cells(6).ToString
                EditarSolicitud((key(0).ToString()))
            End If
            'If e.CommandName = "Del" Then
            '    EliminarSolicitud((key(0).ToString()))
            'End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub MostrarProductos(ByVal strCodigo As String)
        lblProducto.Text = "Productos de la Solicitud de Pedido " & strCodigo.PadLeft(4, "0")
        dgListaProducto.DataSource = SolicitudPedidoProductoBL.ListarxCodigo(CInt(strCodigo))
        dgListaProducto.DataBind()
    End Sub

    'Private Sub EliminarSolicitud(ByVal strCodigo As String)
    '    SolicitudPedidoBL.Eliminar(CInt(strCodigo))
    '    dgDatos.DataSource = SolicitudPedidoBL.ListarTodo
    '    dgDatos.DataBind()
    'End Sub

    Private Sub EditarSolicitud(ByVal strCodigo As String)
        Response.Redirect("EvaluacionSolicitudPedido.aspx?strCodigo=" & strCodigo)
    End Sub
End Class
